home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4501 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.7 KB  |  46 lines

  1. Path: nntp-xfer-2.csn.net!yuma!steffend
  2. From: steffend@lamar.colostate.edu (Dave Steffen)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Newbie question on syntax of pointer to const
  5. Date: 30 Jan 1996 17:40:41 GMT
  6. Organization: Colorado State University, Fort Collins, CO  80523
  7. Message-ID: <4ell6p$3f2q@yuma.ACNS.ColoState.EDU>
  8. References: <4ej9eg$lq6@agate.berkeley.edu> <4ek468$jr1@clarknet.clark.net>
  9. NNTP-Posting-Host: glitch.physics.colostate.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Harlan Messinger (gusty@clark.net) wrote:
  13. > parsons@vouvray.CS.Berkeley.EDU (David C. Parsons) wrote:
  14. > >(1)    const double *pc;    and
  15. > >(2)    double const *pc;
  16.  
  17. > This is one of my favorite questions to ask C/C++ programmers at job
  18. > interviews.
  19.  
  20. > They are different. The first is a pointer to a constant double.
  21. (snip)
  22. > The second is a constant pointer to a double.
  23. (snip)
  24.  
  25.     What I'm curious about is the syntax of that second
  26. line. Looking at Meyers' book, it looks like the const should come
  27. after the *. In other words, are these the same:
  28.  
  29. double const * pc;
  30. double * const pc;
  31.  
  32.     The second syntax I've seen and used; the first I'm not sure
  33. of (and am too lazy to check the DWP right now ;-)
  34.  
  35.                                  /\
  36.                                  \/
  37.  
  38. Dave Steffen                      No, his mind is not for rent
  39. Dept. of Physics                  To any God or Government
  40. Colorado State University         Always hopeful, yet discontent
  41. steffend@lamar.colostate edu      He knows changes aren't permanent-
  42.                       But change is...
  43. "Speak softly...                    
  44. ... and carry a black belt!"              -Neal Peart / RUSH
  45. -----------------------------------------------------------------------
  46.